package org.lennon.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.lennon.service.ParseLog;
import org.lennon.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("RunJobAction")
public class RunJobAction {
	
	@Autowired
	private ParseLog parse;
	
	@SuppressWarnings("deprecation")
	@RequestMapping("RunJob")
	@ResponseBody
	public String entance(String date){
		String project = StringUtil.getProperties("conf/project", "project.name");
		String logPath = StringUtil.getProperties("conf/project", "project.logpath");
		Date dt = new Date(date);
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
		
		String fileName = logPath+df.format(dt)+".txt";
		parse.saveLogFileHistory(fileName);
		parse.loadFromFile(project,fileName );
		
		return "RunJob";
	}
}
